package AVLTree;

import java.util.ArrayList;

public class AvlTreeTest {

    private static double testMap(Map<String, Integer> map, String filename){

        long startTime = System.nanoTime();

        System.out.println(filename);
        ArrayList<String> words = new ArrayList<>();
        if(FileOperation.readFile(filename, words)) {
            System.out.println("Total words: " + words.size());

            for (String word : words){
                if(map.contains(word))
                    map.set(word, map.get(word) + 1);
                else
                    map.add(word, 1);
            }

            System.out.println("Total different words: " + map.getSize());
            System.out.println("Frequency of PRIDE: " + map.get("project"));
            System.out.println("Frequency of PREJUDICE: " + map.get("prejudice"));
        }

        long endTime = System.nanoTime();

        return (endTime - startTime) / 1000000000.0;
    }

    public static void main(String[] args) {
        Map<String,Integer> map = new AvlTree<>();
        System.out.println(testMap(map,"D:\\javaWebItem\\Array\\src\\AVLTree\\pride-and-prejudice.txt"));
        System.out.println(map.isBST());
        System.out.println(map.isBalance());
        map.remove("project");
        System.out.println(map.get("project"));
        System.out.println(map.isBalance());

    }
}
